package com.app.xinfadi.dao;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.app.xinfadi.base.Constant;
import com.app.xinfadi.base.MyApplication;
import com.app.xinfadi.dao_bean.version.VersionUpdateList;
import com.app.xinfadi.util.LogUtil;
import com.app.xinfadi.widget.gson.GsonRequest;

import java.util.HashMap;
import java.util.Map;


/**
 * 版本更新
 *
 * @author WuTengFei <br/>
 * @Function: TODO <br/>
 * @date 2015-5-21 上午11:45:59 <br/>
 */
public class VersionUpdateDao {
    private final static String TAG = VersionUpdateDao.class.getSimpleName();

    public VersionUpdateDao() {
    }

    public void updateVersion(Response.Listener<VersionUpdateList> listener) {
        String URL = Constant.URL + "version/get_update_version";
        GsonRequest<VersionUpdateList> gsonRequest = new GsonRequest<VersionUpdateList>(Request.Method.POST, URL,
                VersionUpdateList.class, listener, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                LogUtil.e("TAG", error.toString());
            }
        }) {

            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> params = new HashMap<String, String>();
//                params.put("org_id", MyApplication.getInstance().getBaseContext().getResources().getString(R.string.org_id));
                return params;
            }
        };
        MyApplication.getInstance().addToRequestQueue(gsonRequest);
    }
}
